
<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta charset="utf-8" />
    <title>9.2. Key types &#8212; PSA Crypto API 1.0.1 documentation</title>
    <link rel="stylesheet" href="../../_static/alabaster.css" type="text/css" />
    <link rel="stylesheet" href="../../_static/pygments.css" type="text/css" />
    <script type="text/javascript" id="documentation_options" data-url_root="../../" src="../../_static/documentation_options.js"></script>
    <script type="text/javascript" src="../../_static/jquery.js"></script>
    <script type="text/javascript" src="../../_static/underscore.js"></script>
    <script type="text/javascript" src="../../_static/doctools.js"></script>
    <script type="text/javascript" src="../../_static/language_data.js"></script>
    <link rel="author" title="About these documents" href="../../about.html" />
    <link rel="index" title="Index" href="../../genindex.html" />
    <link rel="search" title="Search" href="../../search.html" />
    <link rel="next" title="9.3. Key lifetimes" href="lifetimes.html" />
    <link rel="prev" title="9.1. Key attributes" href="attributes.html" />
   
  <link rel="stylesheet" href="../../_static/custom.css" type="text/css" />
  
  
  <meta name="viewport" content="width=device-width, initial-scale=0.9, maximum-scale=0.9" />

  </head><body>
  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          

          <div class="body" role="main">
            
  <div class="section" id="key-types">
<span id="id1"></span><h1>9.2. Key types</h1>
<div class="section" id="key-type-encoding">
<h2>9.2.1. Key type encoding</h2>
<div class="section" id="psa_key_type_t">
<span id="c.psa_key_type_t"></span><h3><code class="docutils literal notranslate"><span class="pre">psa_key_type_t</span></code> (type)</h3>
<p>Encoding of a key type.</p>
<pre class="literal-block">typedef uint16_t <a class="reference internal" href="#c.psa_key_type_t" title="psa_key_type_t">psa_key_type_t</a>;</pre>
<p>This is a structured bitfield that identifies the category and type of key. The range of key type values is divided as follows:</p>
<dl class="simple">
<dt><a class="reference internal" href="#c.PSA_KEY_TYPE_NONE" title="PSA_KEY_TYPE_NONE"><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_NONE</span></code></a><code class="docutils literal notranslate"> <span class="pre">==</span> <span class="pre">0</span></code></dt><dd><p>Reserved as an invalid key type.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">0</span></code><code class="docutils literal notranslate"><span class="pre">x0001</span></code><code class="docutils literal notranslate"> <span class="pre">-</span> <span class="pre">0</span></code><code class="docutils literal notranslate"><span class="pre">x7fff</span></code></dt><dd><p>Specification-defined key types.
Key types defined by this standard always have bit 15 clear.
Unallocated key type values in this range are reserved for future use.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">0</span></code><code class="docutils literal notranslate"><span class="pre">x8000</span></code><code class="docutils literal notranslate"> <span class="pre">-</span> <span class="pre">0</span></code><code class="docutils literal notranslate"><span class="pre">xffff</span></code></dt><dd><p>Implementation-defined key types.
Implementations that define additional key types must use an encoding with bit 15 set.
The related support macros will be easier to write if these key encodings also respect the bitwise structure used by standard encodings.</p>
</dd>
</dl>
</div>
<div class="section" id="PSA_KEY_TYPE_NONE">
<span id="c.PSA_KEY_TYPE_NONE"></span><h3><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_NONE</span></code> (macro)</h3>
<p>An invalid key type value.</p>
<pre class="literal-block">#define <a class="reference internal" href="#c.PSA_KEY_TYPE_NONE" title="PSA_KEY_TYPE_NONE">PSA_KEY_TYPE_NONE</a> ((<a class="reference internal" href="#c.psa_key_type_t" title="psa_key_type_t">psa_key_type_t</a>)0x0000)</pre>
<p>Zero is not the encoding of any key type.</p>
</div>
</div>
<div class="section" id="key-categories">
<h2>9.2.2. Key categories</h2>
<div class="section" id="PSA_KEY_TYPE_IS_UNSTRUCTURED">
<span id="c.PSA_KEY_TYPE_IS_UNSTRUCTURED"></span><h3><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_IS_UNSTRUCTURED</span></code> (macro)</h3>
<p>Whether a key type is an unstructured array of bytes.</p>
<pre class="literal-block">#define <a class="reference internal" href="#c.PSA_KEY_TYPE_IS_UNSTRUCTURED" title="PSA_KEY_TYPE_IS_UNSTRUCTURED">PSA_KEY_TYPE_IS_UNSTRUCTURED</a>(type) <em><a class="reference internal" href="../../overview/implementation.html#specification-defined-value"><span class="std std-ref">/* specification-defined value */</span></a></em></pre>
<p class="rubric">Parameters</p>
<dl class="simple">
<dt> <code class="docutils literal notranslate"><span class="pre">type</span></code></dt><dd><p>A key type (value of type <a class="reference internal" href="#c.psa_key_type_t" title="psa_key_type_t"><code class="xref any c c-type docutils literal notranslate"><span class="pre">psa_key_type_t</span></code></a>).</p>
</dd>
</dl>
<p class="rubric">Description</p>
<p>This encompasses both symmetric keys and non-key data.</p>
<p>See <a class="reference internal" href="#symmetric-keys"><span class="secref">Symmetric keys</span></a> for a list of symmetric key types.</p>
</div>
<div class="section" id="PSA_KEY_TYPE_IS_ASYMMETRIC">
<span id="c.PSA_KEY_TYPE_IS_ASYMMETRIC"></span><h3><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_IS_ASYMMETRIC</span></code> (macro)</h3>
<p>Whether a key type is asymmetric: either a key pair or a public key.</p>
<pre class="literal-block">#define <a class="reference internal" href="#c.PSA_KEY_TYPE_IS_ASYMMETRIC" title="PSA_KEY_TYPE_IS_ASYMMETRIC">PSA_KEY_TYPE_IS_ASYMMETRIC</a>(type) <em><a class="reference internal" href="../../overview/implementation.html#specification-defined-value"><span class="std std-ref">/* specification-defined value */</span></a></em></pre>
<p class="rubric">Parameters</p>
<dl class="simple">
<dt> <code class="docutils literal notranslate"><span class="pre">type</span></code></dt><dd><p>A key type (value of type <a class="reference internal" href="#c.psa_key_type_t" title="psa_key_type_t"><code class="xref any c c-type docutils literal notranslate"><span class="pre">psa_key_type_t</span></code></a>).</p>
</dd>
</dl>
<p class="rubric">Description</p>
<p>See <a class="reference internal" href="#asymmetric-keys"><span class="secref">RSA keys</span></a> for a list of asymmetric key types.</p>
</div>
<div class="section" id="PSA_KEY_TYPE_IS_PUBLIC_KEY">
<span id="c.PSA_KEY_TYPE_IS_PUBLIC_KEY"></span><h3><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_IS_PUBLIC_KEY</span></code> (macro)</h3>
<p>Whether a key type is the public part of a key pair.</p>
<pre class="literal-block">#define <a class="reference internal" href="#c.PSA_KEY_TYPE_IS_PUBLIC_KEY" title="PSA_KEY_TYPE_IS_PUBLIC_KEY">PSA_KEY_TYPE_IS_PUBLIC_KEY</a>(type) <em><a class="reference internal" href="../../overview/implementation.html#specification-defined-value"><span class="std std-ref">/* specification-defined value */</span></a></em></pre>
<p class="rubric">Parameters</p>
<dl class="simple">
<dt> <code class="docutils literal notranslate"><span class="pre">type</span></code></dt><dd><p>A key type (value of type <a class="reference internal" href="#c.psa_key_type_t" title="psa_key_type_t"><code class="xref any c c-type docutils literal notranslate"><span class="pre">psa_key_type_t</span></code></a>).</p>
</dd>
</dl>
</div>
<div class="section" id="PSA_KEY_TYPE_IS_KEY_PAIR">
<span id="c.PSA_KEY_TYPE_IS_KEY_PAIR"></span><h3><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_IS_KEY_PAIR</span></code> (macro)</h3>
<p>Whether a key type is a key pair containing a private part and a public part.</p>
<pre class="literal-block">#define <a class="reference internal" href="#c.PSA_KEY_TYPE_IS_KEY_PAIR" title="PSA_KEY_TYPE_IS_KEY_PAIR">PSA_KEY_TYPE_IS_KEY_PAIR</a>(type) <em><a class="reference internal" href="../../overview/implementation.html#specification-defined-value"><span class="std std-ref">/* specification-defined value */</span></a></em></pre>
<p class="rubric">Parameters</p>
<dl class="simple">
<dt> <code class="docutils literal notranslate"><span class="pre">type</span></code></dt><dd><p>A key type (value of type <a class="reference internal" href="#c.psa_key_type_t" title="psa_key_type_t"><code class="xref any c c-type docutils literal notranslate"><span class="pre">psa_key_type_t</span></code></a>).</p>
</dd>
</dl>
</div>
</div>
<div class="section" id="symmetric-keys">
<span id="id2"></span><h2>9.2.3. Symmetric keys</h2>
<div class="section" id="PSA_KEY_TYPE_RAW_DATA">
<span id="c.PSA_KEY_TYPE_RAW_DATA"></span><h3><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_RAW_DATA</span></code> (macro)</h3>
<p>Raw data.</p>
<pre class="literal-block">#define <a class="reference internal" href="#c.PSA_KEY_TYPE_RAW_DATA" title="PSA_KEY_TYPE_RAW_DATA">PSA_KEY_TYPE_RAW_DATA</a> ((<a class="reference internal" href="#c.psa_key_type_t" title="psa_key_type_t">psa_key_type_t</a>)0x1001)</pre>
<p>A “key” of this type cannot be used for any cryptographic operation. Applications can use this type to store arbitrary data in the keystore.</p>
<p>The bit size of a raw key must be a non-zero multiple of 8. The maximum size of a raw key is <a class="reference internal" href="../../about.html#term-implementation-defined"><span class="scterm">IMPLEMENTATION DEFINED</span></a>.</p>
</div>
<div class="section" id="PSA_KEY_TYPE_HMAC">
<span id="c.PSA_KEY_TYPE_HMAC"></span><h3><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_HMAC</span></code> (macro)</h3>
<p>HMAC key.</p>
<pre class="literal-block">#define <a class="reference internal" href="#c.PSA_KEY_TYPE_HMAC" title="PSA_KEY_TYPE_HMAC">PSA_KEY_TYPE_HMAC</a> ((<a class="reference internal" href="#c.psa_key_type_t" title="psa_key_type_t">psa_key_type_t</a>)0x1100)</pre>
<p>The key policy determines which underlying hash algorithm the key can be used for.</p>
<p>The bit size of an HMAC key must be a non-zero multiple of 8. An HMAC key is typically the same size as the output of the underlying hash algorithm. An HMAC key that is longer than the block size of the underlying hash algorithm will be hashed before use.</p>
<p>When an HMAC key is created that is longer than the block size, it is <a class="reference internal" href="../../about.html#term-implementation-defined"><span class="scterm">implementation defined</span></a> whether the implementation stores the original HMAC key, or the hash of the HMAC key. If the hash of the key is stored, the key size reported by <a class="reference internal" href="attributes.html#c.psa_get_key_attributes" title="psa_get_key_attributes"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_get_key_attributes()</span></code></a> will be the size of the hashed key.</p>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p><a class="reference internal" href="../ops/hashes.html#c.PSA_HASH_LENGTH" title="PSA_HASH_LENGTH"><code class="docutils literal notranslate"><span class="pre">PSA_HASH_LENGTH</span></code></a><code class="docutils literal notranslate"><span class="pre">(</span></code><code class="docutils literal notranslate"><span class="pre">alg</span></code><code class="docutils literal notranslate"><span class="pre">)</span></code> provides the output size of hash algorithm <code class="docutils literal notranslate"><span class="pre">alg</span></code>, in bytes.</p>
<p><a class="reference internal" href="../ops/hashes.html#c.PSA_HASH_BLOCK_LENGTH" title="PSA_HASH_BLOCK_LENGTH"><code class="docutils literal notranslate"><span class="pre">PSA_HASH_BLOCK_LENGTH</span></code></a><code class="docutils literal notranslate"><span class="pre">(</span></code><code class="docutils literal notranslate"><span class="pre">alg</span></code><code class="docutils literal notranslate"><span class="pre">)</span></code> provides the block size of hash algorithm <code class="docutils literal notranslate"><span class="pre">alg</span></code>, in bytes.</p>
</div>
</div>
<div class="section" id="PSA_KEY_TYPE_DERIVE">
<span id="c.PSA_KEY_TYPE_DERIVE"></span><h3><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_DERIVE</span></code> (macro)</h3>
<p>A secret for key derivation.</p>
<pre class="literal-block">#define <a class="reference internal" href="#c.PSA_KEY_TYPE_DERIVE" title="PSA_KEY_TYPE_DERIVE">PSA_KEY_TYPE_DERIVE</a> ((<a class="reference internal" href="#c.psa_key_type_t" title="psa_key_type_t">psa_key_type_t</a>)0x1200)</pre>
<p>The key policy determines which key derivation algorithm the key can be used for.</p>
<p>The bit size of a secret for key derivation must be a non-zero multiple of 8. The maximum size of a secret for key derivation is <a class="reference internal" href="../../about.html#term-implementation-defined"><span class="scterm">IMPLEMENTATION DEFINED</span></a>.</p>
</div>
<div class="section" id="PSA_KEY_TYPE_AES">
<span id="c.PSA_KEY_TYPE_AES"></span><h3><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_AES</span></code> (macro)</h3>
<p>Key for a cipher, AEAD or MAC algorithm based on the AES block cipher.</p>
<pre class="literal-block">#define <a class="reference internal" href="#c.PSA_KEY_TYPE_AES" title="PSA_KEY_TYPE_AES">PSA_KEY_TYPE_AES</a> ((<a class="reference internal" href="#c.psa_key_type_t" title="psa_key_type_t">psa_key_type_t</a>)0x2400)</pre>
<p>The size of the key is related to the AES algorithm variant. For algorithms except the XTS block cipher mode, the following key sizes are used:</p>
<ul class="simple">
<li><p>AES-128 uses a 16-byte key : <code class="docutils literal notranslate"><span class="pre">key_bits</span> <span class="pre">=</span> <span class="pre">128</span></code></p></li>
<li><p>AES-192 uses a 24-byte key : <code class="docutils literal notranslate"><span class="pre">key_bits</span> <span class="pre">=</span> <span class="pre">192</span></code></p></li>
<li><p>AES-256 uses a 32-byte key : <code class="docutils literal notranslate"><span class="pre">key_bits</span> <span class="pre">=</span> <span class="pre">256</span></code></p></li>
</ul>
<p>For the XTS block cipher mode (<a class="reference internal" href="../ops/ciphers.html#c.PSA_ALG_XTS" title="PSA_ALG_XTS"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ALG_XTS</span></code></a>), the following key sizes are used:</p>
<ul class="simple">
<li><p>AES-128-XTS uses two 16-byte keys : <code class="docutils literal notranslate"><span class="pre">key_bits</span> <span class="pre">=</span> <span class="pre">256</span></code></p></li>
<li><p>AES-192-XTS uses two 24-byte keys : <code class="docutils literal notranslate"><span class="pre">key_bits</span> <span class="pre">=</span> <span class="pre">384</span></code></p></li>
<li><p>AES-256-XTS uses two 32-byte keys : <code class="docutils literal notranslate"><span class="pre">key_bits</span> <span class="pre">=</span> <span class="pre">512</span></code></p></li>
</ul>
<p>The AES block cipher is defined in <span><em>FIPS Publication 197: Advanced Encryption Standard (AES)</em> <a class="reference internal" href="../../about.html#citation-fips197"><span class="cite">[FIPS197]</span></a></span>.</p>
</div>
<div class="section" id="PSA_KEY_TYPE_DES">
<span id="c.PSA_KEY_TYPE_DES"></span><h3><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_DES</span></code> (macro)</h3>
<p>Key for a cipher or MAC algorithm based on DES or 3DES (Triple-DES).</p>
<pre class="literal-block">#define <a class="reference internal" href="#c.PSA_KEY_TYPE_DES" title="PSA_KEY_TYPE_DES">PSA_KEY_TYPE_DES</a> ((<a class="reference internal" href="#c.psa_key_type_t" title="psa_key_type_t">psa_key_type_t</a>)0x2301)</pre>
<p>The size of the key determines which DES algorithm is used:</p>
<ul class="simple">
<li><p>Single DES uses an 8-byte key : <code class="docutils literal notranslate"><span class="pre">key_bits</span> <span class="pre">=</span> <span class="pre">64</span></code></p></li>
<li><p>2-key 3DES uses a 16-byte key : <code class="docutils literal notranslate"><span class="pre">key_bits</span> <span class="pre">=</span> <span class="pre">128</span></code></p></li>
<li><p>3-key 3DES uses a 24-byte key : <code class="docutils literal notranslate"><span class="pre">key_bits</span> <span class="pre">=</span> <span class="pre">192</span></code></p></li>
</ul>
<div class="admonition warning">
<p class="admonition-title">Warning</p>
<p>Single DES and 2-key 3DES are weak and strongly deprecated and are only recommended for decrypting legacy data.</p>
<p>3-key 3DES is weak and deprecated and is only recommended for use in legacy protocols.</p>
</div>
<p>The DES and 3DES block ciphers are defined in <span><em>NIST Special Publication 800-67: Recommendation for the Triple Data Encryption Algorithm (TDEA) Block Cipher</em> <a class="reference internal" href="../../about.html#citation-sp800-67"><span class="cite">[SP800-67]</span></a></span>.</p>
</div>
<div class="section" id="PSA_KEY_TYPE_CAMELLIA">
<span id="c.PSA_KEY_TYPE_CAMELLIA"></span><h3><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_CAMELLIA</span></code> (macro)</h3>
<p>Key for a cipher, AEAD or MAC algorithm based on the Camellia block cipher.</p>
<pre class="literal-block">#define <a class="reference internal" href="#c.PSA_KEY_TYPE_CAMELLIA" title="PSA_KEY_TYPE_CAMELLIA">PSA_KEY_TYPE_CAMELLIA</a> ((<a class="reference internal" href="#c.psa_key_type_t" title="psa_key_type_t">psa_key_type_t</a>)0x2403)</pre>
<p>The size of the key is related to the Camellia algorithm variant. For algorithms except the XTS block cipher mode, the following key sizes are used:</p>
<ul class="simple">
<li><p>Camellia-128 uses a 16-byte key : <code class="docutils literal notranslate"><span class="pre">key_bits</span> <span class="pre">=</span> <span class="pre">128</span></code></p></li>
<li><p>Camellia-192 uses a 24-byte key : <code class="docutils literal notranslate"><span class="pre">key_bits</span> <span class="pre">=</span> <span class="pre">192</span></code></p></li>
<li><p>Camellia-256 uses a 32-byte key : <code class="docutils literal notranslate"><span class="pre">key_bits</span> <span class="pre">=</span> <span class="pre">256</span></code></p></li>
</ul>
<p>For the XTS block cipher mode (<a class="reference internal" href="../ops/ciphers.html#c.PSA_ALG_XTS" title="PSA_ALG_XTS"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ALG_XTS</span></code></a>), the following key sizes are used:</p>
<ul class="simple">
<li><p>Camellia-128-XTS uses two 16-byte keys : <code class="docutils literal notranslate"><span class="pre">key_bits</span> <span class="pre">=</span> <span class="pre">256</span></code></p></li>
<li><p>Camellia-192-XTS uses two 24-byte keys : <code class="docutils literal notranslate"><span class="pre">key_bits</span> <span class="pre">=</span> <span class="pre">384</span></code></p></li>
<li><p>Camellia-256-XTS uses two 32-byte keys : <code class="docutils literal notranslate"><span class="pre">key_bits</span> <span class="pre">=</span> <span class="pre">512</span></code></p></li>
</ul>
<p>The Camellia block cipher is defined in <span><em>Specification of Camellia — a 128-bit Block Cipher</em> <a class="reference internal" href="../../about.html#citation-ntt-cam"><span class="cite">[NTT-CAM]</span></a></span> and also described in <span><em>A Description of the Camellia Encryption Algorithm</em> <a class="reference internal" href="../../about.html#citation-rfc3713"><span class="cite">[RFC3713]</span></a></span>.</p>
</div>
<div class="section" id="PSA_KEY_TYPE_SM4">
<span id="c.PSA_KEY_TYPE_SM4"></span><h3><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_SM4</span></code> (macro)</h3>
<p>Key for a cipher, AEAD or MAC algorithm based on the SM4 block cipher.</p>
<pre class="literal-block">#define <a class="reference internal" href="#c.PSA_KEY_TYPE_SM4" title="PSA_KEY_TYPE_SM4">PSA_KEY_TYPE_SM4</a> ((<a class="reference internal" href="#c.psa_key_type_t" title="psa_key_type_t">psa_key_type_t</a>)0x2405)</pre>
<p>For algorithms except the XTS block cipher mode, the SM4 key size is 128 bits (16 bytes).</p>
<p>For the XTS block cipher mode (<a class="reference internal" href="../ops/ciphers.html#c.PSA_ALG_XTS" title="PSA_ALG_XTS"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ALG_XTS</span></code></a>), the SM4 key size is 256 bits (two 16-byte keys).</p>
<p>The SM4 block cipher is defined in <span><em>GB/T 32907-2016: Information security technology — SM4 block cipher algorithm</em> <a class="reference internal" href="../../about.html#citation-prc-sm4"><span class="cite">[PRC-SM4]</span></a></span> and also described in <span><em>The SM4 Blockcipher Algorithm And Its Modes Of Operations</em> <a class="reference internal" href="../../about.html#citation-ietf-sm4"><span class="cite">[IETF-SM4]</span></a></span>.</p>
</div>
<div class="section" id="PSA_KEY_TYPE_ARC4">
<span id="c.PSA_KEY_TYPE_ARC4"></span><h3><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_ARC4</span></code> (macro)</h3>
<p>Key for the ARC4 stream cipher.</p>
<pre class="literal-block">#define <a class="reference internal" href="#c.PSA_KEY_TYPE_ARC4" title="PSA_KEY_TYPE_ARC4">PSA_KEY_TYPE_ARC4</a> ((<a class="reference internal" href="#c.psa_key_type_t" title="psa_key_type_t">psa_key_type_t</a>)0x2002)</pre>
<div class="admonition warning">
<p class="admonition-title">Warning</p>
<p>The ARC4 cipher is weak and deprecated and is only recommended for use in legacy protocols.</p>
</div>
<p>The ARC4 cipher supports key sizes between 40 and 2048 bits, that are multiples of 8. (5 to 256 bytes)</p>
<p>Use algorithm <a class="reference internal" href="../ops/ciphers.html#c.PSA_ALG_STREAM_CIPHER" title="PSA_ALG_STREAM_CIPHER"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ALG_STREAM_CIPHER</span></code></a> to use this key with the ARC4 cipher.</p>
</div>
<div class="section" id="PSA_KEY_TYPE_CHACHA20">
<span id="c.PSA_KEY_TYPE_CHACHA20"></span><h3><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_CHACHA20</span></code> (macro)</h3>
<p>Key for the ChaCha20 stream cipher or the ChaCha20-Poly1305 AEAD algorithm.</p>
<pre class="literal-block">#define <a class="reference internal" href="#c.PSA_KEY_TYPE_CHACHA20" title="PSA_KEY_TYPE_CHACHA20">PSA_KEY_TYPE_CHACHA20</a> ((<a class="reference internal" href="#c.psa_key_type_t" title="psa_key_type_t">psa_key_type_t</a>)0x2004)</pre>
<p>The ChaCha20 key size is 256 bits (32 bytes).</p>
<ul class="simple">
<li><p>Use algorithm <a class="reference internal" href="../ops/ciphers.html#c.PSA_ALG_STREAM_CIPHER" title="PSA_ALG_STREAM_CIPHER"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ALG_STREAM_CIPHER</span></code></a> to use this key with the ChaCha20 cipher for unauthenticated encryption. See <a class="reference internal" href="../ops/ciphers.html#c.PSA_ALG_STREAM_CIPHER" title="PSA_ALG_STREAM_CIPHER"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ALG_STREAM_CIPHER</span></code></a> for details of this algorithm.</p></li>
<li><p>Use algorithm <a class="reference internal" href="../ops/aead.html#c.PSA_ALG_CHACHA20_POLY1305" title="PSA_ALG_CHACHA20_POLY1305"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ALG_CHACHA20_POLY1305</span></code></a> to use this key with the ChaCha20 cipher and Poly1305 authenticator for AEAD. See <a class="reference internal" href="../ops/aead.html#c.PSA_ALG_CHACHA20_POLY1305" title="PSA_ALG_CHACHA20_POLY1305"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ALG_CHACHA20_POLY1305</span></code></a> for details of this algorithm.</p></li>
</ul>
</div>
</div>
<div class="section" id="rsa-keys">
<span id="asymmetric-keys"></span><h2>9.2.4. RSA keys</h2>
<div class="section" id="PSA_KEY_TYPE_RSA_PUBLIC_KEY">
<span id="c.PSA_KEY_TYPE_RSA_PUBLIC_KEY"></span><h3><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_RSA_PUBLIC_KEY</span></code> (macro)</h3>
<p>RSA public key.</p>
<pre class="literal-block">#define <a class="reference internal" href="#c.PSA_KEY_TYPE_RSA_PUBLIC_KEY" title="PSA_KEY_TYPE_RSA_PUBLIC_KEY">PSA_KEY_TYPE_RSA_PUBLIC_KEY</a> ((<a class="reference internal" href="#c.psa_key_type_t" title="psa_key_type_t">psa_key_type_t</a>)0x4001)</pre>
</div>
<div class="section" id="PSA_KEY_TYPE_RSA_KEY_PAIR">
<span id="c.PSA_KEY_TYPE_RSA_KEY_PAIR"></span><h3><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_RSA_KEY_PAIR</span></code> (macro)</h3>
<p>RSA key pair: both the private and public key.</p>
<pre class="literal-block">#define <a class="reference internal" href="#c.PSA_KEY_TYPE_RSA_KEY_PAIR" title="PSA_KEY_TYPE_RSA_KEY_PAIR">PSA_KEY_TYPE_RSA_KEY_PAIR</a> ((<a class="reference internal" href="#c.psa_key_type_t" title="psa_key_type_t">psa_key_type_t</a>)0x7001)</pre>
</div>
<div class="section" id="PSA_KEY_TYPE_IS_RSA">
<span id="c.PSA_KEY_TYPE_IS_RSA"></span><h3><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_IS_RSA</span></code> (macro)</h3>
<p>Whether a key type is an RSA key. This includes both key pairs and public keys.</p>
<pre class="literal-block">#define <a class="reference internal" href="#c.PSA_KEY_TYPE_IS_RSA" title="PSA_KEY_TYPE_IS_RSA">PSA_KEY_TYPE_IS_RSA</a>(type) <em><a class="reference internal" href="../../overview/implementation.html#specification-defined-value"><span class="std std-ref">/* specification-defined value */</span></a></em></pre>
<p class="rubric">Parameters</p>
<dl class="simple">
<dt> <code class="docutils literal notranslate"><span class="pre">type</span></code></dt><dd><p>A key type (value of type <a class="reference internal" href="#c.psa_key_type_t" title="psa_key_type_t"><code class="xref any c c-type docutils literal notranslate"><span class="pre">psa_key_type_t</span></code></a>).</p>
</dd>
</dl>
</div>
</div>
<div class="section" id="elliptic-curve-keys">
<h2>9.2.5. Elliptic Curve keys</h2>
<div class="section" id="psa_ecc_family_t">
<span id="c.psa_ecc_family_t"></span><h3><code class="docutils literal notranslate"><span class="pre">psa_ecc_family_t</span></code> (type)</h3>
<p>The type of PSA elliptic curve family identifiers.</p>
<pre class="literal-block">typedef uint8_t <a class="reference internal" href="#c.psa_ecc_family_t" title="psa_ecc_family_t">psa_ecc_family_t</a>;</pre>
<p>The curve identifier is required to create an ECC key using the <a class="reference internal" href="#c.PSA_KEY_TYPE_ECC_KEY_PAIR" title="PSA_KEY_TYPE_ECC_KEY_PAIR"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_ECC_KEY_PAIR()</span></code></a> or <a class="reference internal" href="#c.PSA_KEY_TYPE_ECC_PUBLIC_KEY" title="PSA_KEY_TYPE_ECC_PUBLIC_KEY"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_ECC_PUBLIC_KEY()</span></code></a> macros.</p>
<p>The specific ECC curve within a family is identified by the <code class="docutils literal notranslate"><span class="pre">key_bits</span></code> attribute of the key.</p>
<p>The range of Elliptic curve family identifier values is divided as follows:</p>
<dl class="simple">
<dt><code class="docutils literal notranslate"><span class="pre">0</span></code><code class="docutils literal notranslate"><span class="pre">x00</span></code><code class="docutils literal notranslate"> <span class="pre">-</span> <span class="pre">0</span></code><code class="docutils literal notranslate"><span class="pre">x7f</span></code></dt><dd><p>ECC family identifiers defined by this standard.
Unallocated values in this range are reserved for future use.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">0</span></code><code class="docutils literal notranslate"><span class="pre">x80</span></code><code class="docutils literal notranslate"> <span class="pre">-</span> <span class="pre">0</span></code><code class="docutils literal notranslate"><span class="pre">xff</span></code></dt><dd><p>Implementations that define additional families must use an encoding in this range.</p>
</dd>
</dl>
</div>
<div class="section" id="PSA_KEY_TYPE_ECC_KEY_PAIR">
<span id="c.PSA_KEY_TYPE_ECC_KEY_PAIR"></span><h3><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_ECC_KEY_PAIR</span></code> (macro)</h3>
<p>Elliptic curve key pair: both the private and public key.</p>
<pre class="literal-block">#define <a class="reference internal" href="#c.PSA_KEY_TYPE_ECC_KEY_PAIR" title="PSA_KEY_TYPE_ECC_KEY_PAIR">PSA_KEY_TYPE_ECC_KEY_PAIR</a>(curve) <em><a class="reference internal" href="../../overview/implementation.html#specification-defined-value"><span class="std std-ref">/* specification-defined value */</span></a></em></pre>
<p class="rubric">Parameters</p>
<dl class="simple">
<dt> <code class="docutils literal notranslate"><span class="pre">curve</span></code></dt><dd><p>A value of type <a class="reference internal" href="#c.psa_ecc_family_t" title="psa_ecc_family_t"><code class="xref any c c-type docutils literal notranslate"><span class="pre">psa_ecc_family_t</span></code></a> that identifies the ECC curve family to be used.</p>
</dd>
</dl>
</div>
<div class="section" id="PSA_KEY_TYPE_ECC_PUBLIC_KEY">
<span id="c.PSA_KEY_TYPE_ECC_PUBLIC_KEY"></span><h3><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_ECC_PUBLIC_KEY</span></code> (macro)</h3>
<p>Elliptic curve public key.</p>
<pre class="literal-block">#define <a class="reference internal" href="#c.PSA_KEY_TYPE_ECC_PUBLIC_KEY" title="PSA_KEY_TYPE_ECC_PUBLIC_KEY">PSA_KEY_TYPE_ECC_PUBLIC_KEY</a>(curve) <em><a class="reference internal" href="../../overview/implementation.html#specification-defined-value"><span class="std std-ref">/* specification-defined value */</span></a></em></pre>
<p class="rubric">Parameters</p>
<dl class="simple">
<dt> <code class="docutils literal notranslate"><span class="pre">curve</span></code></dt><dd><p>A value of type <a class="reference internal" href="#c.psa_ecc_family_t" title="psa_ecc_family_t"><code class="xref any c c-type docutils literal notranslate"><span class="pre">psa_ecc_family_t</span></code></a> that identifies the ECC curve family to be used.</p>
</dd>
</dl>
</div>
<div class="section" id="PSA_ECC_FAMILY_SECP_K1">
<span id="c.PSA_ECC_FAMILY_SECP_K1"></span><h3><code class="docutils literal notranslate"><span class="pre">PSA_ECC_FAMILY_SECP_K1</span></code> (macro)</h3>
<p>SEC Koblitz curves over prime fields.</p>
<pre class="literal-block">#define <a class="reference internal" href="#c.PSA_ECC_FAMILY_SECP_K1" title="PSA_ECC_FAMILY_SECP_K1">PSA_ECC_FAMILY_SECP_K1</a> ((<a class="reference internal" href="#c.psa_ecc_family_t" title="psa_ecc_family_t">psa_ecc_family_t</a>) 0x17)</pre>
<p>This family comprises the following curves:</p>
<ul class="simple">
<li><p>secp192k1 : <code class="docutils literal notranslate"><span class="pre">key_bits</span> <span class="pre">=</span> <span class="pre">192</span></code></p></li>
<li><p>secp224k1 : <code class="docutils literal notranslate"><span class="pre">key_bits</span> <span class="pre">=</span> <span class="pre">225</span></code></p></li>
<li><p>secp256k1 : <code class="docutils literal notranslate"><span class="pre">key_bits</span> <span class="pre">=</span> <span class="pre">256</span></code></p></li>
</ul>
<p>They are defined in <span><em>SEC 2: Recommended Elliptic Curve Domain Parameters</em> <a class="reference internal" href="../../about.html#citation-sec2"><span class="cite">[SEC2]</span></a></span>.</p>
</div>
<div class="section" id="PSA_ECC_FAMILY_SECP_R1">
<span id="c.PSA_ECC_FAMILY_SECP_R1"></span><h3><code class="docutils literal notranslate"><span class="pre">PSA_ECC_FAMILY_SECP_R1</span></code> (macro)</h3>
<p>SEC random curves over prime fields.</p>
<pre class="literal-block">#define <a class="reference internal" href="#c.PSA_ECC_FAMILY_SECP_R1" title="PSA_ECC_FAMILY_SECP_R1">PSA_ECC_FAMILY_SECP_R1</a> ((<a class="reference internal" href="#c.psa_ecc_family_t" title="psa_ecc_family_t">psa_ecc_family_t</a>) 0x12)</pre>
<p>This family comprises the following curves:</p>
<ul class="simple">
<li><p>secp192r1 : <code class="docutils literal notranslate"><span class="pre">key_bits</span> <span class="pre">=</span> <span class="pre">192</span></code></p></li>
<li><p>secp224r1 : <code class="docutils literal notranslate"><span class="pre">key_bits</span> <span class="pre">=</span> <span class="pre">224</span></code></p></li>
<li><p>secp256r1 : <code class="docutils literal notranslate"><span class="pre">key_bits</span> <span class="pre">=</span> <span class="pre">256</span></code></p></li>
<li><p>secp384r1 : <code class="docutils literal notranslate"><span class="pre">key_bits</span> <span class="pre">=</span> <span class="pre">384</span></code></p></li>
<li><p>secp521r1 : <code class="docutils literal notranslate"><span class="pre">key_bits</span> <span class="pre">=</span> <span class="pre">521</span></code></p></li>
</ul>
<p>They are defined in <a class="reference internal" href="../../about.html#citation-sec2"><span class="cite">[SEC2]</span></a>.</p>
</div>
<div class="section" id="PSA_ECC_FAMILY_SECP_R2">
<span id="c.PSA_ECC_FAMILY_SECP_R2"></span><h3><code class="docutils literal notranslate"><span class="pre">PSA_ECC_FAMILY_SECP_R2</span></code> (macro)</h3>
<div class="admonition warning">
<p class="admonition-title">Warning</p>
<p>This family of curves is weak and deprecated.</p>
</div>
<pre class="literal-block">#define <a class="reference internal" href="#c.PSA_ECC_FAMILY_SECP_R2" title="PSA_ECC_FAMILY_SECP_R2">PSA_ECC_FAMILY_SECP_R2</a> ((<a class="reference internal" href="#c.psa_ecc_family_t" title="psa_ecc_family_t">psa_ecc_family_t</a>) 0x1b)</pre>
<p>This family comprises the following curves:</p>
<ul class="simple">
<li><p>secp160r2 : <code class="docutils literal notranslate"><span class="pre">key_bits</span> <span class="pre">=</span> <span class="pre">160</span></code> <em>(Deprecated)</em></p></li>
</ul>
<p>It is defined in the superseded <span><em>SEC 2: Recommended Elliptic Curve Domain Parameters, Version 1.0</em> <a class="reference internal" href="../../about.html#citation-sec2v1"><span class="cite">[SEC2v1]</span></a></span>.</p>
</div>
<div class="section" id="PSA_ECC_FAMILY_SECT_K1">
<span id="c.PSA_ECC_FAMILY_SECT_K1"></span><h3><code class="docutils literal notranslate"><span class="pre">PSA_ECC_FAMILY_SECT_K1</span></code> (macro)</h3>
<p>SEC Koblitz curves over binary fields.</p>
<pre class="literal-block">#define <a class="reference internal" href="#c.PSA_ECC_FAMILY_SECT_K1" title="PSA_ECC_FAMILY_SECT_K1">PSA_ECC_FAMILY_SECT_K1</a> ((<a class="reference internal" href="#c.psa_ecc_family_t" title="psa_ecc_family_t">psa_ecc_family_t</a>) 0x27)</pre>
<p>This family comprises the following curves:</p>
<ul class="simple">
<li><p>sect163k1 : <code class="docutils literal notranslate"><span class="pre">key_bits</span> <span class="pre">=</span> <span class="pre">163</span></code> <em>(Deprecated)</em></p></li>
<li><p>sect233k1 : <code class="docutils literal notranslate"><span class="pre">key_bits</span> <span class="pre">=</span> <span class="pre">233</span></code></p></li>
<li><p>sect239k1 : <code class="docutils literal notranslate"><span class="pre">key_bits</span> <span class="pre">=</span> <span class="pre">239</span></code></p></li>
<li><p>sect283k1 : <code class="docutils literal notranslate"><span class="pre">key_bits</span> <span class="pre">=</span> <span class="pre">283</span></code></p></li>
<li><p>sect409k1 : <code class="docutils literal notranslate"><span class="pre">key_bits</span> <span class="pre">=</span> <span class="pre">409</span></code></p></li>
<li><p>sect571k1 : <code class="docutils literal notranslate"><span class="pre">key_bits</span> <span class="pre">=</span> <span class="pre">571</span></code></p></li>
</ul>
<p>They are defined in <a class="reference internal" href="../../about.html#citation-sec2"><span class="cite">[SEC2]</span></a>.</p>
<div class="admonition warning">
<p class="admonition-title">Warning</p>
<p>The 163-bit curve sect163k1 is weak and deprecated and is only recommended for use in legacy protocols.</p>
</div>
</div>
<div class="section" id="PSA_ECC_FAMILY_SECT_R1">
<span id="c.PSA_ECC_FAMILY_SECT_R1"></span><h3><code class="docutils literal notranslate"><span class="pre">PSA_ECC_FAMILY_SECT_R1</span></code> (macro)</h3>
<p>SEC random curves over binary fields.</p>
<pre class="literal-block">#define <a class="reference internal" href="#c.PSA_ECC_FAMILY_SECT_R1" title="PSA_ECC_FAMILY_SECT_R1">PSA_ECC_FAMILY_SECT_R1</a> ((<a class="reference internal" href="#c.psa_ecc_family_t" title="psa_ecc_family_t">psa_ecc_family_t</a>) 0x22)</pre>
<p>This family comprises the following curves:</p>
<ul class="simple">
<li><p>sect163r1 : <code class="docutils literal notranslate"><span class="pre">key_bits</span> <span class="pre">=</span> <span class="pre">163</span></code> <em>(Deprecated)</em></p></li>
<li><p>sect233r1 : <code class="docutils literal notranslate"><span class="pre">key_bits</span> <span class="pre">=</span> <span class="pre">233</span></code></p></li>
<li><p>sect283r1 : <code class="docutils literal notranslate"><span class="pre">key_bits</span> <span class="pre">=</span> <span class="pre">283</span></code></p></li>
<li><p>sect409r1 : <code class="docutils literal notranslate"><span class="pre">key_bits</span> <span class="pre">=</span> <span class="pre">409</span></code></p></li>
<li><p>sect571r1 : <code class="docutils literal notranslate"><span class="pre">key_bits</span> <span class="pre">=</span> <span class="pre">571</span></code></p></li>
</ul>
<p>They are defined in <a class="reference internal" href="../../about.html#citation-sec2"><span class="cite">[SEC2]</span></a>.</p>
<div class="admonition warning">
<p class="admonition-title">Warning</p>
<p>The 163-bit curve sect163r1 is weak and deprecated and is only recommended for use in legacy protocols.</p>
</div>
</div>
<div class="section" id="PSA_ECC_FAMILY_SECT_R2">
<span id="c.PSA_ECC_FAMILY_SECT_R2"></span><h3><code class="docutils literal notranslate"><span class="pre">PSA_ECC_FAMILY_SECT_R2</span></code> (macro)</h3>
<p>SEC additional random curves over binary fields.</p>
<pre class="literal-block">#define <a class="reference internal" href="#c.PSA_ECC_FAMILY_SECT_R2" title="PSA_ECC_FAMILY_SECT_R2">PSA_ECC_FAMILY_SECT_R2</a> ((<a class="reference internal" href="#c.psa_ecc_family_t" title="psa_ecc_family_t">psa_ecc_family_t</a>) 0x2b)</pre>
<p>This family comprises the following curves:</p>
<ul class="simple">
<li><p>sect163r2 : <code class="docutils literal notranslate"><span class="pre">key_bits</span> <span class="pre">=</span> <span class="pre">163</span></code> <em>(Deprecated)</em></p></li>
</ul>
<p>It is defined in <a class="reference internal" href="../../about.html#citation-sec2"><span class="cite">[SEC2]</span></a>.</p>
<div class="admonition warning">
<p class="admonition-title">Warning</p>
<p>The 163-bit curve sect163r2 is weak and deprecated and is only recommended for use in legacy protocols.</p>
</div>
</div>
<div class="section" id="PSA_ECC_FAMILY_BRAINPOOL_P_R1">
<span id="c.PSA_ECC_FAMILY_BRAINPOOL_P_R1"></span><h3><code class="docutils literal notranslate"><span class="pre">PSA_ECC_FAMILY_BRAINPOOL_P_R1</span></code> (macro)</h3>
<p>Brainpool P random curves.</p>
<pre class="literal-block">#define <a class="reference internal" href="#c.PSA_ECC_FAMILY_BRAINPOOL_P_R1" title="PSA_ECC_FAMILY_BRAINPOOL_P_R1">PSA_ECC_FAMILY_BRAINPOOL_P_R1</a> ((<a class="reference internal" href="#c.psa_ecc_family_t" title="psa_ecc_family_t">psa_ecc_family_t</a>) 0x30)</pre>
<p>This family comprises the following curves:</p>
<ul class="simple">
<li><p>brainpoolP160r1 : <code class="docutils literal notranslate"><span class="pre">key_bits</span> <span class="pre">=</span> <span class="pre">160</span></code> <em>(Deprecated)</em></p></li>
<li><p>brainpoolP192r1 : <code class="docutils literal notranslate"><span class="pre">key_bits</span> <span class="pre">=</span> <span class="pre">192</span></code></p></li>
<li><p>brainpoolP224r1 : <code class="docutils literal notranslate"><span class="pre">key_bits</span> <span class="pre">=</span> <span class="pre">224</span></code></p></li>
<li><p>brainpoolP256r1 : <code class="docutils literal notranslate"><span class="pre">key_bits</span> <span class="pre">=</span> <span class="pre">256</span></code></p></li>
<li><p>brainpoolP320r1 : <code class="docutils literal notranslate"><span class="pre">key_bits</span> <span class="pre">=</span> <span class="pre">320</span></code></p></li>
<li><p>brainpoolP384r1 : <code class="docutils literal notranslate"><span class="pre">key_bits</span> <span class="pre">=</span> <span class="pre">384</span></code></p></li>
<li><p>brainpoolP512r1 : <code class="docutils literal notranslate"><span class="pre">key_bits</span> <span class="pre">=</span> <span class="pre">512</span></code></p></li>
</ul>
<p>They are defined in <span><em>Elliptic Curve Cryptography (ECC) Brainpool Standard Curves and Curve Generation</em> <a class="reference internal" href="../../about.html#citation-rfc5639"><span class="cite">[RFC5639]</span></a></span>.</p>
<div class="admonition warning">
<p class="admonition-title">Warning</p>
<p>The 160-bit curve brainpoolP160r1 is weak and deprecated and is only recommended for use in legacy protocols.</p>
</div>
</div>
<div class="section" id="PSA_ECC_FAMILY_FRP">
<span id="c.PSA_ECC_FAMILY_FRP"></span><h3><code class="docutils literal notranslate"><span class="pre">PSA_ECC_FAMILY_FRP</span></code> (macro)</h3>
<p>Curve used primarily in France and elsewhere in Europe.</p>
<pre class="literal-block">#define <a class="reference internal" href="#c.PSA_ECC_FAMILY_FRP" title="PSA_ECC_FAMILY_FRP">PSA_ECC_FAMILY_FRP</a> ((<a class="reference internal" href="#c.psa_ecc_family_t" title="psa_ecc_family_t">psa_ecc_family_t</a>) 0x33)</pre>
<p>This family comprises one 256-bit curve:</p>
<ul class="simple">
<li><p>FRP256v1 : <code class="docutils literal notranslate"><span class="pre">key_bits</span> <span class="pre">=</span> <span class="pre">256</span></code></p></li>
</ul>
<p>This is defined by <span><em>Publication d'un paramétrage de courbe elliptique visant des applications de passeport électronique et de l'administration électronique française</em> <a class="reference internal" href="../../about.html#citation-frp"><span class="cite">[FRP]</span></a></span>.</p>
</div>
<div class="section" id="PSA_ECC_FAMILY_MONTGOMERY">
<span id="c.PSA_ECC_FAMILY_MONTGOMERY"></span><h3><code class="docutils literal notranslate"><span class="pre">PSA_ECC_FAMILY_MONTGOMERY</span></code> (macro)</h3>
<p>Montgomery curves.</p>
<pre class="literal-block">#define <a class="reference internal" href="#c.PSA_ECC_FAMILY_MONTGOMERY" title="PSA_ECC_FAMILY_MONTGOMERY">PSA_ECC_FAMILY_MONTGOMERY</a> ((<a class="reference internal" href="#c.psa_ecc_family_t" title="psa_ecc_family_t">psa_ecc_family_t</a>) 0x41)</pre>
<p>This family comprises the following Montgomery curves:</p>
<ul class="simple">
<li><p>Curve25519 : <code class="docutils literal notranslate"><span class="pre">key_bits</span> <span class="pre">=</span> <span class="pre">255</span></code></p></li>
<li><p>Curve448 : <code class="docutils literal notranslate"><span class="pre">key_bits</span> <span class="pre">=</span> <span class="pre">448</span></code></p></li>
</ul>
<p>Keys in this family can only be used with the <a class="reference internal" href="../ops/ka.html#c.PSA_ALG_ECDH" title="PSA_ALG_ECDH"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ALG_ECDH</span></code></a> key agreement algorithm.</p>
<p>Curve25519 is defined in <span><em>Curve25519: new Diffie-Hellman speed records</em> <a class="reference internal" href="../../about.html#citation-curve25519"><span class="cite">[Curve25519]</span></a></span>. Curve448 is defined in <span><em>Ed448-Goldilocks, a new elliptic curve</em> <a class="reference internal" href="../../about.html#citation-curve448"><span class="cite">[Curve448]</span></a></span>.</p>
</div>
<div class="section" id="PSA_KEY_TYPE_IS_ECC">
<span id="c.PSA_KEY_TYPE_IS_ECC"></span><h3><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_IS_ECC</span></code> (macro)</h3>
<p>Whether a key type is an elliptic curve key, either a key pair or a public key.</p>
<pre class="literal-block">#define <a class="reference internal" href="#c.PSA_KEY_TYPE_IS_ECC" title="PSA_KEY_TYPE_IS_ECC">PSA_KEY_TYPE_IS_ECC</a>(type) <em><a class="reference internal" href="../../overview/implementation.html#specification-defined-value"><span class="std std-ref">/* specification-defined value */</span></a></em></pre>
<p class="rubric">Parameters</p>
<dl class="simple">
<dt> <code class="docutils literal notranslate"><span class="pre">type</span></code></dt><dd><p>A key type (value of type <a class="reference internal" href="#c.psa_key_type_t" title="psa_key_type_t"><code class="xref any c c-type docutils literal notranslate"><span class="pre">psa_key_type_t</span></code></a>).</p>
</dd>
</dl>
</div>
<div class="section" id="PSA_KEY_TYPE_IS_ECC_KEY_PAIR">
<span id="c.PSA_KEY_TYPE_IS_ECC_KEY_PAIR"></span><h3><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_IS_ECC_KEY_PAIR</span></code> (macro)</h3>
<p>Whether a key type is an elliptic curve key pair.</p>
<pre class="literal-block">#define <a class="reference internal" href="#c.PSA_KEY_TYPE_IS_ECC_KEY_PAIR" title="PSA_KEY_TYPE_IS_ECC_KEY_PAIR">PSA_KEY_TYPE_IS_ECC_KEY_PAIR</a>(type) <em><a class="reference internal" href="../../overview/implementation.html#specification-defined-value"><span class="std std-ref">/* specification-defined value */</span></a></em></pre>
<p class="rubric">Parameters</p>
<dl class="simple">
<dt> <code class="docutils literal notranslate"><span class="pre">type</span></code></dt><dd><p>A key type (value of type <a class="reference internal" href="#c.psa_key_type_t" title="psa_key_type_t"><code class="xref any c c-type docutils literal notranslate"><span class="pre">psa_key_type_t</span></code></a>).</p>
</dd>
</dl>
</div>
<div class="section" id="PSA_KEY_TYPE_IS_ECC_PUBLIC_KEY">
<span id="c.PSA_KEY_TYPE_IS_ECC_PUBLIC_KEY"></span><h3><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_IS_ECC_PUBLIC_KEY</span></code> (macro)</h3>
<p>Whether a key type is an elliptic curve public key.</p>
<pre class="literal-block">#define <a class="reference internal" href="#c.PSA_KEY_TYPE_IS_ECC_PUBLIC_KEY" title="PSA_KEY_TYPE_IS_ECC_PUBLIC_KEY">PSA_KEY_TYPE_IS_ECC_PUBLIC_KEY</a>(type) <em><a class="reference internal" href="../../overview/implementation.html#specification-defined-value"><span class="std std-ref">/* specification-defined value */</span></a></em></pre>
<p class="rubric">Parameters</p>
<dl class="simple">
<dt> <code class="docutils literal notranslate"><span class="pre">type</span></code></dt><dd><p>A key type (value of type <a class="reference internal" href="#c.psa_key_type_t" title="psa_key_type_t"><code class="xref any c c-type docutils literal notranslate"><span class="pre">psa_key_type_t</span></code></a>).</p>
</dd>
</dl>
</div>
<div class="section" id="PSA_KEY_TYPE_ECC_GET_FAMILY">
<span id="c.PSA_KEY_TYPE_ECC_GET_FAMILY"></span><h3><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_ECC_GET_FAMILY</span></code> (macro)</h3>
<p>Extract the curve family from an elliptic curve key type.</p>
<pre class="literal-block">#define <a class="reference internal" href="#c.PSA_KEY_TYPE_ECC_GET_FAMILY" title="PSA_KEY_TYPE_ECC_GET_FAMILY">PSA_KEY_TYPE_ECC_GET_FAMILY</a>(type) <em><a class="reference internal" href="../../overview/implementation.html#specification-defined-value"><span class="std std-ref">/* specification-defined value */</span></a></em></pre>
<p class="rubric">Parameters</p>
<dl class="simple">
<dt> <code class="docutils literal notranslate"><span class="pre">type</span></code></dt><dd><p>An elliptic curve key type (value of type <a class="reference internal" href="#c.psa_key_type_t" title="psa_key_type_t"><code class="xref any c c-type docutils literal notranslate"><span class="pre">psa_key_type_t</span></code></a> such that <a class="reference internal" href="#c.PSA_KEY_TYPE_IS_ECC" title="PSA_KEY_TYPE_IS_ECC"><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_IS_ECC</span></code></a><code class="docutils literal notranslate"><span class="pre">(</span></code><code class="docutils literal notranslate"><span class="pre">type</span></code><code class="docutils literal notranslate"><span class="pre">)</span></code> is true).</p>
</dd>
</dl>
<p class="rubric">Returns: <a class="reference internal" href="#c.psa_ecc_family_t" title="psa_ecc_family_t"><code class="docutils literal notranslate"><span class="pre">psa_ecc_family_t</span></code></a></p>
<p>The elliptic curve family id, if <code class="docutils literal notranslate"><span class="pre">type</span></code> is a supported elliptic curve key. Unspecified if <code class="docutils literal notranslate"><span class="pre">type</span></code> is not a supported elliptic curve key.</p>
</div>
</div>
<div class="section" id="diffie-hellman-keys">
<h2>9.2.6. Diffie Hellman keys</h2>
<div class="section" id="psa_dh_family_t">
<span id="c.psa_dh_family_t"></span><h3><code class="docutils literal notranslate"><span class="pre">psa_dh_family_t</span></code> (type)</h3>
<p>The type of PSA finite-field Diffie-Hellman group family identifiers.</p>
<pre class="literal-block">typedef uint8_t <a class="reference internal" href="#c.psa_dh_family_t" title="psa_dh_family_t">psa_dh_family_t</a>;</pre>
<p>The group family identifier is required to create a finite-field Diffie-Hellman key using the <a class="reference internal" href="#c.PSA_KEY_TYPE_DH_KEY_PAIR" title="PSA_KEY_TYPE_DH_KEY_PAIR"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_DH_KEY_PAIR()</span></code></a> or <a class="reference internal" href="#c.PSA_KEY_TYPE_DH_PUBLIC_KEY" title="PSA_KEY_TYPE_DH_PUBLIC_KEY"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_DH_PUBLIC_KEY()</span></code></a> macros.</p>
<p>The specific Diffie-Hellman group within a family is identified by the <code class="docutils literal notranslate"><span class="pre">key_bits</span></code> attribute of the key.</p>
<p>The range of Diffie-Hellman group family identifier values is divided as follows:</p>
<dl class="simple">
<dt><code class="docutils literal notranslate"><span class="pre">0</span></code><code class="docutils literal notranslate"><span class="pre">x00</span></code><code class="docutils literal notranslate"> <span class="pre">-</span> <span class="pre">0</span></code><code class="docutils literal notranslate"><span class="pre">x7f</span></code></dt><dd><p>DH group family identifiers defined by this standard.
Unallocated values in this range are reserved for future use.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">0</span></code><code class="docutils literal notranslate"><span class="pre">x80</span></code><code class="docutils literal notranslate"> <span class="pre">-</span> <span class="pre">0</span></code><code class="docutils literal notranslate"><span class="pre">xff</span></code></dt><dd><p>Implementations that define additional families must use an encoding in this range.</p>
</dd>
</dl>
</div>
<div class="section" id="PSA_KEY_TYPE_DH_KEY_PAIR">
<span id="c.PSA_KEY_TYPE_DH_KEY_PAIR"></span><h3><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_DH_KEY_PAIR</span></code> (macro)</h3>
<p>Finite-field Diffie-Hellman key pair: both the private key and public key.</p>
<pre class="literal-block">#define <a class="reference internal" href="#c.PSA_KEY_TYPE_DH_KEY_PAIR" title="PSA_KEY_TYPE_DH_KEY_PAIR">PSA_KEY_TYPE_DH_KEY_PAIR</a>(group) <em><a class="reference internal" href="../../overview/implementation.html#specification-defined-value"><span class="std std-ref">/* specification-defined value */</span></a></em></pre>
<p class="rubric">Parameters</p>
<dl class="simple">
<dt> <code class="docutils literal notranslate"><span class="pre">group</span></code></dt><dd><p>A value of type <a class="reference internal" href="#c.psa_dh_family_t" title="psa_dh_family_t"><code class="xref any c c-type docutils literal notranslate"><span class="pre">psa_dh_family_t</span></code></a> that identifies the Diffie-Hellman group family to be used.</p>
</dd>
</dl>
</div>
<div class="section" id="PSA_KEY_TYPE_DH_PUBLIC_KEY">
<span id="c.PSA_KEY_TYPE_DH_PUBLIC_KEY"></span><h3><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_DH_PUBLIC_KEY</span></code> (macro)</h3>
<p>Finite-field Diffie-Hellman public key.</p>
<pre class="literal-block">#define <a class="reference internal" href="#c.PSA_KEY_TYPE_DH_PUBLIC_KEY" title="PSA_KEY_TYPE_DH_PUBLIC_KEY">PSA_KEY_TYPE_DH_PUBLIC_KEY</a>(group) <em><a class="reference internal" href="../../overview/implementation.html#specification-defined-value"><span class="std std-ref">/* specification-defined value */</span></a></em></pre>
<p class="rubric">Parameters</p>
<dl class="simple">
<dt> <code class="docutils literal notranslate"><span class="pre">group</span></code></dt><dd><p>A value of type <a class="reference internal" href="#c.psa_dh_family_t" title="psa_dh_family_t"><code class="xref any c c-type docutils literal notranslate"><span class="pre">psa_dh_family_t</span></code></a> that identifies the Diffie-Hellman group family to be used.</p>
</dd>
</dl>
</div>
<div class="section" id="PSA_DH_FAMILY_RFC7919">
<span id="c.PSA_DH_FAMILY_RFC7919"></span><h3><code class="docutils literal notranslate"><span class="pre">PSA_DH_FAMILY_RFC7919</span></code> (macro)</h3>
<p>Finite-field Diffie-Hellman groups defined for TLS in RFC 7919.</p>
<pre class="literal-block">#define <a class="reference internal" href="#c.PSA_DH_FAMILY_RFC7919" title="PSA_DH_FAMILY_RFC7919">PSA_DH_FAMILY_RFC7919</a> ((<a class="reference internal" href="#c.psa_dh_family_t" title="psa_dh_family_t">psa_dh_family_t</a>) 0x03)</pre>
<p>This family includes groups with the following key sizes (in bits): 2048, 3072, 4096, 6144, 8192.
An implementation can support all of these sizes or only a subset.</p>
<p>Keys is this group can only be used with the <a class="reference internal" href="../ops/ka.html#c.PSA_ALG_FFDH" title="PSA_ALG_FFDH"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ALG_FFDH</span></code></a> key agreement algorithm.</p>
<p>These groups are defined by <span><em>Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for Transport Layer Security (TLS)</em> <a class="reference internal" href="../../about.html#citation-rfc7919"><span class="cite">[RFC7919]</span></a></span> <a class="reference external" href="https://tools.ietf.org/html/rfc7919.html#appendix-A">Appendix A</a>.</p>
</div>
<div class="section" id="PSA_KEY_TYPE_KEY_PAIR_OF_PUBLIC_KEY">
<span id="c.PSA_KEY_TYPE_KEY_PAIR_OF_PUBLIC_KEY"></span><h3><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_KEY_PAIR_OF_PUBLIC_KEY</span></code> (macro)</h3>
<p>The key pair type corresponding to a public key type.</p>
<pre class="literal-block">#define <a class="reference internal" href="#c.PSA_KEY_TYPE_KEY_PAIR_OF_PUBLIC_KEY" title="PSA_KEY_TYPE_KEY_PAIR_OF_PUBLIC_KEY">PSA_KEY_TYPE_KEY_PAIR_OF_PUBLIC_KEY</a>(type) \
    <em><a class="reference internal" href="../../overview/implementation.html#specification-defined-value"><span class="std std-ref">/* specification-defined value */</span></a></em></pre>
<p class="rubric">Parameters</p>
<dl class="simple">
<dt> <code class="docutils literal notranslate"><span class="pre">type</span></code></dt><dd><p>A public key type or key pair type.</p>
</dd>
</dl>
<p class="rubric">Returns</p>
<p>The corresponding key pair type. If <code class="docutils literal notranslate"><span class="pre">type</span></code> is not a public key or a key pair, the return value is undefined.</p>
<p class="rubric">Description</p>
<p>If <code class="docutils literal notranslate"><span class="pre">type</span></code> is a key pair type, it will be left unchanged.</p>
</div>
<div class="section" id="PSA_KEY_TYPE_PUBLIC_KEY_OF_KEY_PAIR">
<span id="c.PSA_KEY_TYPE_PUBLIC_KEY_OF_KEY_PAIR"></span><h3><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_PUBLIC_KEY_OF_KEY_PAIR</span></code> (macro)</h3>
<p>The public key type corresponding to a key pair type.</p>
<pre class="literal-block">#define <a class="reference internal" href="#c.PSA_KEY_TYPE_PUBLIC_KEY_OF_KEY_PAIR" title="PSA_KEY_TYPE_PUBLIC_KEY_OF_KEY_PAIR">PSA_KEY_TYPE_PUBLIC_KEY_OF_KEY_PAIR</a>(type) \
    <em><a class="reference internal" href="../../overview/implementation.html#specification-defined-value"><span class="std std-ref">/* specification-defined value */</span></a></em></pre>
<p class="rubric">Parameters</p>
<dl class="simple">
<dt> <code class="docutils literal notranslate"><span class="pre">type</span></code></dt><dd><p>A public key type or key pair type.</p>
</dd>
</dl>
<p class="rubric">Returns</p>
<p>The corresponding public key type. If <code class="docutils literal notranslate"><span class="pre">type</span></code> is not a public key or a key pair, the return value is undefined.</p>
<p class="rubric">Description</p>
<p>If <code class="docutils literal notranslate"><span class="pre">type</span></code> is a public key type, it will be left unchanged.</p>
</div>
<div class="section" id="PSA_KEY_TYPE_IS_DH">
<span id="c.PSA_KEY_TYPE_IS_DH"></span><h3><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_IS_DH</span></code> (macro)</h3>
<p>Whether a key type is a Diffie-Hellman key, either a key pair or a public key.</p>
<pre class="literal-block">#define <a class="reference internal" href="#c.PSA_KEY_TYPE_IS_DH" title="PSA_KEY_TYPE_IS_DH">PSA_KEY_TYPE_IS_DH</a>(type) <em><a class="reference internal" href="../../overview/implementation.html#specification-defined-value"><span class="std std-ref">/* specification-defined value */</span></a></em></pre>
<p class="rubric">Parameters</p>
<dl class="simple">
<dt> <code class="docutils literal notranslate"><span class="pre">type</span></code></dt><dd><p>A key type (value of type <a class="reference internal" href="#c.psa_key_type_t" title="psa_key_type_t"><code class="xref any c c-type docutils literal notranslate"><span class="pre">psa_key_type_t</span></code></a>).</p>
</dd>
</dl>
</div>
<div class="section" id="PSA_KEY_TYPE_IS_DH_KEY_PAIR">
<span id="c.PSA_KEY_TYPE_IS_DH_KEY_PAIR"></span><h3><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_IS_DH_KEY_PAIR</span></code> (macro)</h3>
<p>Whether a key type is a Diffie-Hellman key pair.</p>
<pre class="literal-block">#define <a class="reference internal" href="#c.PSA_KEY_TYPE_IS_DH_KEY_PAIR" title="PSA_KEY_TYPE_IS_DH_KEY_PAIR">PSA_KEY_TYPE_IS_DH_KEY_PAIR</a>(type) <em><a class="reference internal" href="../../overview/implementation.html#specification-defined-value"><span class="std std-ref">/* specification-defined value */</span></a></em></pre>
<p class="rubric">Parameters</p>
<dl class="simple">
<dt> <code class="docutils literal notranslate"><span class="pre">type</span></code></dt><dd><p>A key type (value of type <a class="reference internal" href="#c.psa_key_type_t" title="psa_key_type_t"><code class="xref any c c-type docutils literal notranslate"><span class="pre">psa_key_type_t</span></code></a>).</p>
</dd>
</dl>
</div>
<div class="section" id="PSA_KEY_TYPE_IS_DH_PUBLIC_KEY">
<span id="c.PSA_KEY_TYPE_IS_DH_PUBLIC_KEY"></span><h3><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_IS_DH_PUBLIC_KEY</span></code> (macro)</h3>
<p>Whether a key type is a Diffie-Hellman public key.</p>
<pre class="literal-block">#define <a class="reference internal" href="#c.PSA_KEY_TYPE_IS_DH_PUBLIC_KEY" title="PSA_KEY_TYPE_IS_DH_PUBLIC_KEY">PSA_KEY_TYPE_IS_DH_PUBLIC_KEY</a>(type) <em><a class="reference internal" href="../../overview/implementation.html#specification-defined-value"><span class="std std-ref">/* specification-defined value */</span></a></em></pre>
<p class="rubric">Parameters</p>
<dl class="simple">
<dt> <code class="docutils literal notranslate"><span class="pre">type</span></code></dt><dd><p>A key type (value of type <a class="reference internal" href="#c.psa_key_type_t" title="psa_key_type_t"><code class="xref any c c-type docutils literal notranslate"><span class="pre">psa_key_type_t</span></code></a>).</p>
</dd>
</dl>
</div>
<div class="section" id="PSA_KEY_TYPE_DH_GET_FAMILY">
<span id="c.PSA_KEY_TYPE_DH_GET_FAMILY"></span><h3><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_DH_GET_FAMILY</span></code> (macro)</h3>
<p>Extract the group family from a Diffie-Hellman key type.</p>
<pre class="literal-block">#define <a class="reference internal" href="#c.PSA_KEY_TYPE_DH_GET_FAMILY" title="PSA_KEY_TYPE_DH_GET_FAMILY">PSA_KEY_TYPE_DH_GET_FAMILY</a>(type) <em><a class="reference internal" href="../../overview/implementation.html#specification-defined-value"><span class="std std-ref">/* specification-defined value */</span></a></em></pre>
<p class="rubric">Parameters</p>
<dl class="simple">
<dt> <code class="docutils literal notranslate"><span class="pre">type</span></code></dt><dd><p>A Diffie-Hellman key type (value of type <a class="reference internal" href="#c.psa_key_type_t" title="psa_key_type_t"><code class="xref any c c-type docutils literal notranslate"><span class="pre">psa_key_type_t</span></code></a> such that <a class="reference internal" href="#c.PSA_KEY_TYPE_IS_DH" title="PSA_KEY_TYPE_IS_DH"><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_IS_DH</span></code></a><code class="docutils literal notranslate"><span class="pre">(</span></code><code class="docutils literal notranslate"><span class="pre">type</span></code><code class="docutils literal notranslate"><span class="pre">)</span></code> is true).</p>
</dd>
</dl>
<p class="rubric">Returns: <a class="reference internal" href="#c.psa_dh_family_t" title="psa_dh_family_t"><code class="docutils literal notranslate"><span class="pre">psa_dh_family_t</span></code></a></p>
<p>The Diffie-Hellman group family id, if <code class="docutils literal notranslate"><span class="pre">type</span></code> is a supported Diffie-Hellman key. Unspecified if <code class="docutils literal notranslate"><span class="pre">type</span></code> is not a supported Diffie-Hellman key.</p>
</div>
</div>
<div class="section" id="attribute-accessors">
<h2>9.2.7. Attribute accessors</h2>
<div class="section" id="psa_set_key_type">
<span id="c.psa_set_key_type"></span><h3><code class="docutils literal notranslate"><span class="pre">psa_set_key_type</span></code> (function)</h3>
<p>Declare the type of a key.</p>
<pre class="literal-block">void <a class="reference internal" href="#c.psa_set_key_type" title="psa_set_key_type">psa_set_key_type</a>(<a class="reference internal" href="attributes.html#c.psa_key_attributes_t" title="psa_key_attributes_t">psa_key_attributes_t</a> * attributes,
                      <a class="reference internal" href="#c.psa_key_type_t" title="psa_key_type_t">psa_key_type_t</a> type);</pre>
<p class="rubric">Parameters</p>
<dl class="simple">
<dt> <code class="docutils literal notranslate"><span class="pre">attributes</span></code></dt><dd><p>The attribute object to write to.</p>
</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">type</span></code></dt><dd><p>The key type to write. If this is <a class="reference internal" href="#c.PSA_KEY_TYPE_NONE" title="PSA_KEY_TYPE_NONE"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_NONE</span></code></a>, the key type in <code class="docutils literal notranslate"><span class="pre">attributes</span></code> becomes unspecified.</p>
</dd>
</dl>
<p class="rubric">Returns: <code class="docutils literal notranslate"><span class="pre">void</span></code></p>
<p class="rubric">Description</p>
<p>This function overwrites any key type previously set in <code class="docutils literal notranslate"><span class="pre">attributes</span></code>.</p>
<div class="admonition-implementation-note admonition">
<p class="admonition-title">Implementation note</p>
<p>This is a simple accessor function that is not required to validate its inputs. The following approaches can be used to provide an efficient implementation:</p>
<ul class="simple">
<li><p>This function can be declared as <code class="docutils literal notranslate"><span class="pre">static</span></code> or <code class="docutils literal notranslate"><span class="pre">inline</span></code>, instead of using the default external linkage.</p></li>
<li><p>This function can be provided as a function-like macro. In this form, the macro must evaluate each of its arguments exactly once, as if it was a function call.</p></li>
</ul>
</div>
</div>
<div class="section" id="psa_get_key_type">
<span id="c.psa_get_key_type"></span><h3><code class="docutils literal notranslate"><span class="pre">psa_get_key_type</span></code> (function)</h3>
<p>Retrieve the key type from key attributes.</p>
<pre class="literal-block"><a class="reference internal" href="#c.psa_key_type_t" title="psa_key_type_t">psa_key_type_t</a> <a class="reference internal" href="#c.psa_get_key_type" title="psa_get_key_type">psa_get_key_type</a>(const <a class="reference internal" href="attributes.html#c.psa_key_attributes_t" title="psa_key_attributes_t">psa_key_attributes_t</a> * attributes);</pre>
<p class="rubric">Parameters</p>
<dl class="simple">
<dt> <code class="docutils literal notranslate"><span class="pre">attributes</span></code></dt><dd><p>The key attribute object to query.</p>
</dd>
</dl>
<p class="rubric">Returns: <a class="reference internal" href="#c.psa_key_type_t" title="psa_key_type_t"><code class="docutils literal notranslate"><span class="pre">psa_key_type_t</span></code></a></p>
<p>The key type stored in the attribute object.</p>
<p class="rubric">Description</p>
<div class="admonition-implementation-note admonition">
<p class="admonition-title">Implementation note</p>
<p>This is a simple accessor function that is not required to validate its inputs. The following approaches can be used to provide an efficient implementation:</p>
<ul class="simple">
<li><p>This function can be declared as <code class="docutils literal notranslate"><span class="pre">static</span></code> or <code class="docutils literal notranslate"><span class="pre">inline</span></code>, instead of using the default external linkage.</p></li>
<li><p>This function can be provided as a function-like macro. In this form, the macro must evaluate each of its arguments exactly once, as if it was a function call.</p></li>
</ul>
</div>
</div>
<div class="section" id="psa_get_key_bits">
<span id="c.psa_get_key_bits"></span><h3><code class="docutils literal notranslate"><span class="pre">psa_get_key_bits</span></code> (function)</h3>
<p>Retrieve the key size from key attributes.</p>
<pre class="literal-block">size_t <a class="reference internal" href="#c.psa_get_key_bits" title="psa_get_key_bits">psa_get_key_bits</a>(const <a class="reference internal" href="attributes.html#c.psa_key_attributes_t" title="psa_key_attributes_t">psa_key_attributes_t</a> * attributes);</pre>
<p class="rubric">Parameters</p>
<dl class="simple">
<dt> <code class="docutils literal notranslate"><span class="pre">attributes</span></code></dt><dd><p>The key attribute object to query.</p>
</dd>
</dl>
<p class="rubric">Returns: <code class="docutils literal notranslate"><span class="pre">size_t</span></code></p>
<p>The key size stored in the attribute object, in bits.</p>
<p class="rubric">Description</p>
<div class="admonition-implementation-note admonition">
<p class="admonition-title">Implementation note</p>
<p>This is a simple accessor function that is not required to validate its inputs. The following approaches can be used to provide an efficient implementation:</p>
<ul class="simple">
<li><p>This function can be declared as <code class="docutils literal notranslate"><span class="pre">static</span></code> or <code class="docutils literal notranslate"><span class="pre">inline</span></code>, instead of using the default external linkage.</p></li>
<li><p>This function can be provided as a function-like macro. In this form, the macro must evaluate each of its arguments exactly once, as if it was a function call.</p></li>
</ul>
</div>
</div>
<div class="section" id="psa_set_key_bits">
<span id="c.psa_set_key_bits"></span><h3><code class="docutils literal notranslate"><span class="pre">psa_set_key_bits</span></code> (function)</h3>
<p>Declare the size of a key.</p>
<pre class="literal-block">void <a class="reference internal" href="#c.psa_set_key_bits" title="psa_set_key_bits">psa_set_key_bits</a>(<a class="reference internal" href="attributes.html#c.psa_key_attributes_t" title="psa_key_attributes_t">psa_key_attributes_t</a> * attributes,
                      size_t bits);</pre>
<p class="rubric">Parameters</p>
<dl class="simple">
<dt> <code class="docutils literal notranslate"><span class="pre">attributes</span></code></dt><dd><p>The attribute object to write to.</p>
</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">bits</span></code></dt><dd><p>The key size in bits. If this is <code class="docutils literal notranslate"><span class="pre">0</span></code>, the key size in <code class="docutils literal notranslate"><span class="pre">attributes</span></code> becomes unspecified. Keys of size <code class="docutils literal notranslate"><span class="pre">0</span></code> are not supported.</p>
</dd>
</dl>
<p class="rubric">Returns: <code class="docutils literal notranslate"><span class="pre">void</span></code></p>
<p class="rubric">Description</p>
<p>This function overwrites any key size previously set in <code class="docutils literal notranslate"><span class="pre">attributes</span></code>.</p>
<div class="admonition-implementation-note admonition">
<p class="admonition-title">Implementation note</p>
<p>This is a simple accessor function that is not required to validate its inputs. The following approaches can be used to provide an efficient implementation:</p>
<ul class="simple">
<li><p>This function can be declared as <code class="docutils literal notranslate"><span class="pre">static</span></code> or <code class="docutils literal notranslate"><span class="pre">inline</span></code>, instead of using the default external linkage.</p></li>
<li><p>This function can be provided as a function-like macro. In this form, the macro must evaluate each of its arguments exactly once, as if it was a function call.</p></li>
</ul>
</div>
</div>
</div>
</div>


          </div>
          
        </div>
      </div>
      <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
        <div class="sphinxsidebarwrapper"><h3><a href="../../index.html"><b>PSA Crypto API</b></a></h3>
IHI 0086<br/>
Non-confidential<br/>
Version 1.0.1
<span style="color: red; font-weight: bold;"></span>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../about.html">About this document</a></li>
</ul>
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="../../overview/intro.html">1. Introduction</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../overview/goals.html">2. Design goals</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../overview/functionality.html">3. Functionality overview</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../overview/sample-arch.html">4. Sample architectures</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../overview/conventions.html">5. Library conventions</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../overview/implementation.html">6. Implementation considerations</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../overview/usage.html">7. Usage considerations</a></li>
<li class="toctree-l1"><a class="reference internal" href="../library/index.html">8. Library management reference</a></li>
<li class="toctree-l1 current"><a class="reference internal" href="index.html">9. Key management reference</a><ul class="current">
<li class="toctree-l2"><a class="reference internal" href="attributes.html">9.1. Key attributes</a></li>
<li class="toctree-l2 current"><a class="current reference internal" href="#">9.2. Key types</a><ul>
<li class="toctree-l3"><a class="reference internal" href="#key-type-encoding">9.2.1. Key type encoding</a></li>
<li class="toctree-l3"><a class="reference internal" href="#key-categories">9.2.2. Key categories</a></li>
<li class="toctree-l3"><a class="reference internal" href="#symmetric-keys">9.2.3. Symmetric keys</a></li>
<li class="toctree-l3"><a class="reference internal" href="#rsa-keys">9.2.4. RSA keys</a></li>
<li class="toctree-l3"><a class="reference internal" href="#elliptic-curve-keys">9.2.5. Elliptic Curve keys</a></li>
<li class="toctree-l3"><a class="reference internal" href="#diffie-hellman-keys">9.2.6. Diffie Hellman keys</a></li>
<li class="toctree-l3"><a class="reference internal" href="#attribute-accessors">9.2.7. Attribute accessors</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="lifetimes.html">9.3. Key lifetimes</a></li>
<li class="toctree-l2"><a class="reference internal" href="ids.html">9.4. Key identifiers</a></li>
<li class="toctree-l2"><a class="reference internal" href="policy.html">9.5. Key policies</a></li>
<li class="toctree-l2"><a class="reference internal" href="management.html">9.6. Key management functions</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../ops/index.html">10. Cryptographic operation reference</a></li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../appendix/example_header.html">Example header file</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../appendix/specdef_values.html">Example macro implementations</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../appendix/history.html">Changes to the API</a></li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../psa_c-identifiers.html">Index of API elements</a></li>
</ul>
<div id="searchbox" style="display: none" role="search">
  <h3 id="searchlabel">Quick search</h3>
    <div class="searchformwrapper">
    <form class="search" action="../../search.html" method="get">
      <input type="text" name="q" aria-labelledby="searchlabel" />
      <input type="submit" value="Go" />
    </form>
    </div>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="footer">
      &copy; 2018-2020, Arm Limited or its affiliates. All rights reserved.
      
      |
      Powered by <a href="http://sphinx-doc.org/">Sphinx 2.1.2</a>
      &amp; <a href="https://github.com/bitprophet/alabaster">Alabaster 0.7.12</a>
      
    </div>

    

    
  </body>
</html>